<?php
/**
 * Dependency classes analyzer
 *
 * PHP version 5
 *
 * @category  W
 * @package   Services
 * @author    Olivier Hoareau <olivier@phppro.fr>
 * @copyright 2009 PHPPRO http://www.phppro.fr
 * @license   http://dev.phppro.fr/license PHPPRO
 * @version   SVN: $Id:$
 * @link      http://dev.phppro.fr/projects/wdependency
 */
require_once 'W/Dependency/Analyzer/Abstract.php';
/**
 * Dependency classes analyzer
 *
 * @category  W
 * @package   Services
 * @author    Olivier Hoareau <olivier@phppro.fr>
 * @copyright 2009 PHPPRO http://www.phppro.fr
 * @license   http://dev.phppro.fr/license PHPPRO
 * @version   SVN: $Id$
 * @link      http://dev.phppro.fr/projects/wdependency
 */
class W_Dependency_Analyzer_Classes extends W_Dependency_Analyzer_Abstract
{
    public function compute($data,$root)
    {
        $d = array();
        foreach($data as $file=>$info) {
            if (false === isset($info['class'])) {
                continue;
            }
            $class = $info['class'][0];
            $found = false;
            foreach(array_keys($info) as $key) {
		    if (true === isset($info[$key])) {
			    $dd = array();
			foreach($info[$key] as $subNode) {
				if (false === isset($data[$subNode['value']]['class'][0])) {
					continue;
				}
				$dd[] = $subNode;
			}
                    $this->updateDependencies($d,$class,$dd,$root);
                    $found = true;
                }
            }
            if (false === $found) {
                if (false === isset($d[$class])) {
                    $d[$class] = array();
                }
            }
        }
        return $d;
    }
}
